package cn.zqy.demo.day10.demo02;

// 笔记本类
public class Demo05Computer {
    public void powerOff() {
        System.out.println("关闭电源关机！！");
    }

    public void powerOn() {
        System.out.println("打开电源开机！！");
    }

    public void usbDevice(Demo05Usb usb) {
        if(usb instanceof Demo05Keyboard) {
            // 要使用对象自身方法。向下转型
            Demo05Keyboard keyboard = (Demo05Keyboard) usb;
            keyboard.print();
        } else if(usb instanceof  Demo05Mouse) {
            Demo05Mouse us = (Demo05Mouse) usb;
            us.click();
        }
    }
}
